




import  requests
import parsel
from fontTools.ttLib import TTFont
from getFont import haveFornt
if __name__ == '__main__':
    
    headers = {
        'Cookie': 'Hm_lvt_2667d29c8e792e6fa9182c20a3013175=1716438629; csrf_session_id=cb69e6cf3b1af43a88a56157e7795f2e; '
              +'novel_web_id=7372047678422058532; s_v_web_id=verify_lwir8sbl_HcMwpu3M_DoJp_4RKG_BcMo_izZ4lEmNBlEQ; '
                +'Hm_lpvt_2667d29c8e792e6fa9182c20a3013175=1716454389; ttwid=1%7CRpx4a-wFaDG9-ogRfl7wXC7k61DQkWYwkb_Q2THE'
                +'qb4%7C1716454388%7Cb80bb1f8f2ccd546e6a1ccd1b1abb9151e31bbf5d48e3224451a90b7ca5d534c; msToken=-9U5-TOe5X2'
               +'axgeeY4G28F-tp-R7o8gDaOF5p2fPPvcNdZYLXWU9JiPv_tOU81HeXCDT52o4UtGOLCZmuDMN2I8yulNK-8hIUpNSHiEVK3ke5aEeG'
               + 'J4wDhk_cQgJ3g==',
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36'
    }

    url = 'https://fanqienovel.com/page/7276384138653862966'

    # response = requests.get(url=url, headers=headers)

    # html = response.text
    
    # selector = parsel.Selector(html)

    #  获取第一个
    # print(selector.css(".chapter-item-title::text").get())
    # 获取所有
    # print(selector.css(".chapter-item-title::text").getall())
    # 获取属性值
    # print(selector.css(".chapter-item-title::attr(href)").getall())

    # # 所有的书本id
    # chapterIdList = selector.css(".chapter-item-title::attr(href)").getall()

    # # 章节名
    # chapteNameList = selector.css(".chapter-item-title::text").getall()

    # chapt = []

    # for title, id in zip(chapteNameList, chapterIdList):
    #     chapt.append({title, id})

    # print(chapt)


    # 提取小说内容
    link_url = 'https://fanqienovel.com/reader' + '/7412580498557387288'

    contentHtml = requests.get(url=link_url, headers=headers).text
 
    contentSelector = parsel.Selector(contentHtml)
 
    contentText = contentSelector.css(".muye-reader-content-16 p::text").getall()
    haveFornt(contentText)
    # for d in contentText:
    #     for x in d:
    #         print("--->", x,  )
 